﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Theme_index_UserControls_News : System.Web.UI.UserControl
{
    PowerCreator.LMS.Web.CMS.New opNews = new PowerCreator.LMS.Web.CMS.New();
    protected void Page_Load(object sender, EventArgs e)
    {
        //教育咨询
        BinderNews();
    }
    private void BinderNews()
    {
        string search = " NewState = 1 and ((FKNewTrainclaIDList is null) or (FKNewTrainclaIDList='')) and NewID not in (select top 5 NewID from Tnew where NewPictureUrl is not null order by NewPublishTime desc) and FKNewNewTypeID = (select top 1 NewTypeID from TNewType where NewTypeName='教育资讯' )  ";
        string orderBy = " NewPublishTime desc ";
        DataTable dt = opNews.Query(search, orderBy, 7, 1);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["NewUrl"] == null)
                dt.Rows[i]["NewUrl"] = "OpenNews.aspx?NewsID=" + dt.Rows[i]["NewID"].ToString();
            else if (dt.Rows[i]["NewUrl"].ToString().Length == 0)
                dt.Rows[i]["NewUrl"] = "OpenNews.aspx?NewsID=" + dt.Rows[i]["NewID"].ToString();
        }
        rpt_News.DataSource = dt;
        rpt_News.DataBind();

    }
}
